package com.mingchuang.administrator.mingchuang;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.mingchuang.administrator.mingchuang.utils.Constant;

import java.io.File;

public class TakePicActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_take_pic);


        File file = new File(Constant.getPath()+File.separator+"zhycheng.jpg");

        Uri uri = Uri.fromFile(file);
        Intent i=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        i.putExtra(MediaStore.Images.Media.ORIENTATION, 0);
        i.putExtra(MediaStore.EXTRA_OUTPUT, uri);

        startActivityForResult(i, 9);


    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if(resultCode==RESULT_OK)
        {
            if(requestCode==9)
            {

                /*File  bb=new File(Constant.getPath()+File.separator+"zhycheng.jpg");

                Intent i=new Intent("com.android.camera.action.CROP");
                i.setType("image*//*");


                //i.putExtra("data", bb);
                i.setDataAndType(Uri.fromFile(bb), "image/jpeg");

                i.putExtra("crop", "true");

                i.putExtra("aspectX", 1);

                i.putExtra("aspectY", 1);

                i.putExtra("outputX", 500);

                i.putExtra("outputY", 500);

                i.putExtra("return-data", true);

                this.startActivityForResult(i, 7);*/




            }

        }


    }
}
